<?php
function manga_mobile_render_theloai(){
	$cache=new cache;
	$str=$cache->load('mobile_manga_theloai','anime');
	if(!$str){
	 $db=new db;
	 $db->connect();
	 $db->query('select * from anime_theloai  order by name asc');
	 $data=$db->fetchAll();
	
	 

			
				foreach( $data as $row){
						$str.='<a href="'.mangaf1_url_manga_theloai($row['id'],$row['alias']).'" class="btn btn-default btn-menu">'.$row['name'].'</a>';
					
				}
	
			

	$cache->save('mobile_manga_theloai',$str,3600,'anime');	
	}
	return $str;
}


function manga_mobile_render_group_item_hot($data){
	if($data){
	$str= "<div class='list-group'>";
			$j=1;
			foreach($data as $row){
					if($j%2==0){
											   $str.='<div class="each-small-item item-even">';
										}else{
												$str.='<div class="each-small-item item-odd">';
										}
													$str.='	<a class="small-image-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'"><img class="img-right" src="'.$row['hinhanh'].'" alt="" /></a>
														<a class="small-title-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'">'.$row['name'].'</a>
														<span class="featured-item-new-chapt"><a href="'.$row['ep_moinhaturl'].'">'.$row['ep_moinhat'].'</a></span>
                                                        <div class="small-item-theloai " >';
														
														$vl=mangaf2_get_manga_theloai($row['theloai']);
														$str.=$vl[2].'</div>';
														$nguon=mangaf2_get_manga_nguon($row['nguon']);
														$str.='<div class="small-item-group">'.$nguon.'</div>
                                                        
                                                        <div class="clr"></div>
												</div>';
									
									$j++;
							
				
			} // End foreach 
		
		$str.='</div>';
		return $str;
	} else{// End !$data
		return  "<h4>Chưa có dữ liệu</h4>";
	}
}
 
 
 
 function manga_mobile_get_list_hot(){
		
		$sql ="select c.id as chapid,c.status,c.ten,c.seourl,c.index_show,c.hot,c.new,m.name,m.theloai,m.nguon,m.id,m.alias,m.nguon,m.theloai,m.hinhanh from chapterk2 as c
		left join anime as m
		on c.manga=m.id 
		where c.home=1 order by ngaythem desc,c.id desc limit 0,20 ";
		$db=new db;
		$db->connect();
		$db->query($sql);
		$data=$db->fetchAll();
		
	
		return $data;

}// End function get truyen view


 function manga_mobile_get_list_update(){
		
			$db=new db;
			$db->connect();
		$db->query("SELECT mg.id, mg.name,mg.alias,mg.hinhanh,mg.theloai,mg.nguon,chap.ten, chap.id as chapid,chap.hot,chap.new, chap.seourl,chap.index_show,chap.status,chap.ngaythem
								FROM chapterk2 AS chap, anime AS mg
								WHERE  chap.index_show!='' and chap.manga = mg.id
								ORDER BY chap.ngaythem desc,chap.id desc
								LIMIT 0 ,40");
				$dt=$db->fetchAll();
			$db->close();	
		
	
	return $dt;

}// End function get truyen view


function manga_render_group_item_mobile($data,$url=''){
	
	if($data){
		$str= "<div class='mobile_viewmore'><a href='$url'>Xem hết &raquo;</a></div><div class='clr'></div>";
	$str.= "<div class='list-group'>";
			$j=1;
			foreach($data as $row){
					if($j%2==0){
											   $str.='<div class="each-small-item item-even">';
										}else{
												$str.='<div class="each-small-item item-odd">';
										}
													$str.='	<a class="small-image-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'"><img class="img-right lazy" data-original="'.mangaf1_picasa_link($row['hinhanh'],100).'" alt="" /></a>
														<a class="small-title-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'">'.$row['name'].' ';
														if($row['hot']==1){
														$str.='<span class="panel-label panel-hot">HOT</span>';
														}
														if($row['new']==1){
														$str.='<span class="panel-label panel-new">NEW</span>';
														}
														$str.='</a>';
														$str.='<span class="featured-item-new-chapt"><a href="'.mangaf1_url_manga_episode($row['chapid'],$row['seourl'],$row['alias']).'">'.$row['index_show'].' <em>'.$row['status'].'</em></a></span>
                                                        <div class="small-item-theloai " >';
														
														$vl=mangaf2_get_manga_theloai($row['theloai']);
														$str.=$vl[2].'</div>';
														$nguon=mangaf2_get_manga_nguon($row['nguon']);
														$str.='<div class="small-item-group">'.$nguon.'</div>
                                                        
                                                        <div class="clr"></div>
												</div>';
									
									$j++;
							
				
			} // End foreach 
		
		$str.='</div>';
		$str.="<div class='mobile_viewmore'><a href='$url'>Xem Thêm</a></div>";
		return $str;
	} else{// End !$data
		return  "<h4>Chưa có dữ liệu</h4>";
	}
}

?>